package io.renren.modules.groupinfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.welderunnormal.entity.WelderunnormalEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.groupinfo.entity.GroupinfoEntity;
import io.renren.modules.groupinfo.service.GroupinfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-12-28 15:17:34
 */
@RestController
@RequestMapping("groupinfo/groupinfo")
public class GroupinfoController {
    @Autowired
    private GroupinfoService groupinfoService;

    @GetMapping("getgroupinfo")
    public List<GroupinfoEntity> getgroupinfo(@RequestParam(value = "groupName",required = false) String groupName, @RequestParam(value = "leaderName",required = false) String leaderName){
        return groupinfoService.getgroupinfo(groupName,leaderName);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("groupinfo:groupinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = groupinfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{groupid}")
    @RequiresPermissions("groupinfo:groupinfo:info")
    public R info(@PathVariable("groupid") Integer groupid){
		GroupinfoEntity groupinfo = groupinfoService.getById(groupid);

        return R.ok().put("groupinfo", groupinfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("groupinfo:groupinfo:save")
    public R save(@RequestBody GroupinfoEntity groupinfo){
		groupinfoService.save(groupinfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("groupinfo:groupinfo:update")
    public R update(@RequestBody GroupinfoEntity groupinfo){
		groupinfoService.updateById(groupinfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("groupinfo:groupinfo:delete")
    public R delete(@RequestBody Integer[] groupids){
		groupinfoService.removeByIds(Arrays.asList(groupids));

        return R.ok();
    }

}
